package com.feige.utils.regex;

import java.util.regex.Pattern;

/**
 * @author feige<br />
 * @ClassName: RegexUtil <br/>
 * @Description: <br/>
 * @date: 2021/8/22 15:11<br/>
 */
public class RegexUtil {

    /**
     * 邮箱正则表达式
     */
    public static final Pattern EMAIL_PATTERN = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");


    /**
     * 电话正则表达式
     */
    public static final  Pattern MOBILE_PATTERN = Pattern.compile("^(13[4,5,6,7,8,9]|15[0,8,9,1,7]|188|187)\\d{8}$");


    /**
     * @description: 是否是邮箱
     * @author: feige
     * @date: 2021/8/22 15:15
     * @param	email
     * @return: boolean
     */
    public static boolean isEmail(String email){
        return EMAIL_PATTERN.matcher(email).matches();
    }

    /**
     * @description: 是否电话
     * @author: feige
     * @date: 2021/8/22 15:15
     * @param	mobile
     * @return: boolean
     */
    public static boolean isMobile(String mobile){
        return MOBILE_PATTERN.matcher(mobile).matches();
    }
}
